package screen;

import framework.Key;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;

import framework.Util;
import framework.Screen;
import game.Global;
import java.util.ArrayList;
import java.util.List;

public class GameIntrodutionScreen extends Screen {
    private List<Image> title;
    private int cont;
    private int indice;

    public GameIntrodutionScreen() {
        title = new ArrayList<Image>();
        title.add(Util.loadImage(Global.IMG_GAME_INTRO1));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO2));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO3));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO4));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO5));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO6));
        title.add(Util.loadImage(Global.IMG_GAME_INTRO6));

        cont = 0;
        indice = 0;


    }

    public void paint(Graphics g) {
        g.drawImage(title.get(indice), 0, 0, null);

    }

    public void update() {

        cont++;

        if(cont>=800){
            indice++;
            cont = 0;
            if(indice>=6)
                Screen.setCurrentScreen(new GameLevelScreen());

        }


        if (Key.isTyped(KeyEvent.VK_D) || Key.isTyped(KeyEvent.VK_ENTER)) {
            // iniciar jogo
           Screen.setCurrentScreen(new GameLevelScreen());
        }else
        if (Key.isTyped(KeyEvent.VK_ESCAPE)) {
            // sair do jogo
            Screen.setCurrentScreen(new TitleScreen());
        }else
            if (Key.isTyped(KeyEvent.VK_RIGHT)&& indice<title.size()) {
                cont = 0;
                indice++;

            }
        else
            if (Key.isTyped(KeyEvent.VK_LEFT) && indice>0) {
                indice--;
                cont = 0;

            }
    }
}
